clear
use ${data}teacher_data

* Limit to Chicago region
keep if region==1

* Macro with only individual teacher covariates
local Xind "gpa undergrad_satmt75 undergrad_sat_ms  major_soc major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female black hispanic otherRace"

 eststo clear
foreach c in step1 step2 step3 step45 completedCorps { 
	
	reg `c' da i.hs i.CorpsYear  $X , cluster(region_gl)
	eststo `c'
	gen s=e(sample)
	estadd scalar p = 2*ttail(1,abs(_b[da]/_se[da])): `c'
	qui su `c' if da==1 & s==1
	estadd scalar cm = round(r(mean) - _b[da],.001): `c'
	drop s
	
	
}
	
 estout completedCorps step1 step2 step3 step45    using ${results}table5_panelA.txt, replace ///
	keep(da) cells(b(star fmt(2) nostar)  se(par fmt(2))) ///
	collabels(,none) stat(p cm  N) 
	
	
	
* ---------------------- *	
* Parallel Trends Figure *
* ---------------------- *

reg completedCorps da2009 da2010 da2011 da2012 da2014  i.hs i.CorpsYear  $X  , cluster(region_gl)	


matrix coef = J(6,3,.)
local row=0
foreach y in 2009 2010 2011 2012   { 
	local row=`row'+1
	matrix coef[`row',1] = `y'
	matrix coef[`row',2] = _b[da`y']
	matrix coef[`row',3] = _se[da`y']
}
matrix coef[5,1] = 2013
matrix coef[5,2] = 0
matrix coef[5,3] = 0
matrix coef[6,1] = 2014
matrix coef[6,2] = _b[da2014]
matrix coef[6,3] = _se[da2014]
	
clear
svmat coef
ren coef1 cohort
ren coef2 effect

* Confidence intervals use 1 degree of freedom
gen lb = effect - 12.7062*coef3
gen ub = effect + 12.7062*coef3


		
graph twoway (connected effect cohort, lcolor(black) mcolor(black)) (rcap ub lb cohort, lcolor(black)), xline(2013.1, lcolor(black) lpattern(dash))    legend(label(1 "Effect")  label(2 "95% Confidence Interval") pos(6) cols(1)) graphregion(color(white)) xtitle("Cohort") ytitle("HS-Elementary Difference") 
graph export ${results}figure3_panelA.png, replace
	
	
	
exit	
	